const Router = require('koa-router')

const momentRouter = new Router({prefix: '/moment'})

const { 
    create,
    detail,
    list,
    update,
    addLabels,
    remove,
    fileInfo,
    hotlist,
    momentList,
    userMomentList
} = require('../controller/moment.cotroller')

const { 
    verifyAuth,
    verifyPermission
} = require('../middleware/auth.middleware')
const {
    verifyLabelExists
} = require('../middleware/label.middleware');

momentRouter.post('/', verifyAuth, create)
momentRouter.get('/hotPosts', hotlist)

momentRouter.get('/momentList', verifyAuth, momentList)
momentRouter.get('/userMomentList', verifyAuth, userMomentList)
momentRouter.get('/:momentId', detail)
momentRouter.get('/', list)


// 修改动态的接口 需要验证是否登录   是否具备修改权限 然后更新
momentRouter.patch('/:momentId', verifyAuth, verifyPermission, update)
momentRouter.delete('/:momentId', verifyAuth, verifyPermission, remove)
momentRouter.get('/images/:filename', fileInfo);

// 给动态添加标签
momentRouter.post('/:postsId/labels', verifyAuth, verifyPermission, verifyLabelExists, addLabels);
module.exports = momentRouter
